package com.ysu.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ysu.shop.pojo.User;
import com.ysu.shop.mapper.UserMapper;
import com.ysu.shop.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 霍京
 * @since 2021-3-03
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public User getUserById(int id) {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("id",id);
        return userMapper.getUserById(wrapper);
    }

    @Override
    public int updatePwd(int id, String oldPwd, String newPwd) {
        return userMapper.updatePwd(id,oldPwd,newPwd);
    }

    @Override
    public int updatePwdByAnswer(int id, String answer, String newPwd) {
        return userMapper.updatePwdByAnswer(id,answer,newPwd);
    }
}
